home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Files / CatInfo.h < prev    next >
Text File  |  1997-06-28  |  9KB  |  206 lines

  1. // CatInfo.h
  2.  
  3. #ifndef CatInfo_h
  4. #define CatInfo_h
  5.  
  6. #ifndef FileLocation_h
  7. #include "FileLocation.h"
  8. #endif
  9. #ifndef __FINDER__
  10. #include <Finder.h>
  11. #endif
  12.  
  13. class CatInfo: public CInfoPBRec
  14.   {
  15.     private:
  16.         FileLocation location;
  17.         
  18.         void ThrowError( OSErr );
  19.         
  20.         bool Attribute( uint8 bit ) const                                { return ( hFileInfo.ioFlAttrib & bit ) != 0; }
  21.         bool Flag( uint16 bit ) const                                        { return ( hFileInfo.ioFlFndrInfo.fdFlags & bit ) != 0; }
  22.         void SetFlag( uint16 bit )                                            { hFileInfo.ioFlFndrInfo.fdFlags |= bit; }
  23.         void ClearFlag( uint16 bit )                                        { hFileInfo.ioFlFndrInfo.fdFlags &= ~bit; }
  24.  
  25.     public:
  26.         CatInfo();
  27.         CatInfo( const FileLocation& );
  28.         CatInfo( ::Directory );
  29.         CatInfo( ::Directory, ConstPString );
  30.         CatInfo( ::Directory, int16 index );
  31.         
  32.         CatInfo( const CatInfo& );
  33.         void operator=( const CatInfo& );
  34.         
  35.         void Get();
  36.         void Get( const FileLocation& );
  37.         void Get( ::Directory );
  38.         void Get( ::Directory, ConstPString );
  39.         void Get( ::Directory, int16 index );
  40.         
  41.         void Set();
  42.         void Set( const FileLocation& );
  43.         
  44.         bool IsRoot() const                                                    { return location.IsRoot(); }
  45.         
  46.         void Up();
  47.         void Down( ConstPString );
  48.         void Sideways( ConstPString );
  49.         
  50.         const FileLocation& Location() const                            { return location; }
  51.         ::Directory AsDirectory() const;
  52.         
  53.         bool Locked() const                                                    { return Attribute( 0x01 ); }
  54.         bool IsDirectory() const                                            { return Attribute( 0x10 ); }
  55.         
  56.         bool Invisible() const                                                { return Flag( fInvisible ); }
  57.         bool NameLocked() const                                                { return Flag( kNameLocked ); }
  58.         bool HasCustomIcon() const                                            { return Flag( kHasCustomIcon ); }
  59.         bool SeenByFinder() const                                            { return Flag( kHasBeenInited ); }
  60.  
  61.         void BeInvisible()                                                    { SetFlag( fInvisible ); }
  62.         void LockName()                                                        { SetFlag( kNameLocked ); }
  63.         void HaveCustomIcon()                                                { SetFlag( kHasCustomIcon ); }
  64.         void BeSeenByFinder()                                                { SetFlag( kHasBeenInited ); }
  65.  
  66.         void BeVisible()                                                        { ClearFlag( fInvisible ); }
  67.         void UnlockName()                                                        { ClearFlag( kNameLocked ); }
  68.         void HaveNoCustomIcon()                                                { ClearFlag( kHasCustomIcon ); }
  69.         void BeUnseenByFinder()                                                { ClearFlag( kHasBeenInited ); }
  70.  
  71.         uint8 Label() const                                                    { return ( hFileInfo.ioFlFndrInfo.fdFlags & kColor ) >> 1; }
  72.         void SetLabel( uint8 );
  73.         
  74.         Point LocationInWindow() const                                    { return hFileInfo.ioFlFndrInfo.fdLocation; }
  75.         void SetLocationInWindow( Point p )                                { hFileInfo.ioFlFndrInfo.fdLocation = p; }
  76.  
  77.         uint32 CreationTime() const                                        { return hFileInfo.ioFlCrDat; }
  78.         uint32 ModificationTime() const                                    { return hFileInfo.ioFlMdDat; }
  79.         uint32 BackupTime() const                                            { return hFileInfo.ioFlBkDat; }
  80.  
  81.         void SetCreationTime( uint32 t )                                    { hFileInfo.ioFlCrDat = t; }
  82.         void SetModificationTime( uint32 t )                            { hFileInfo.ioFlMdDat = t; }
  83.         void SetBackupTime( uint32 t )                                    { hFileInfo.ioFlBkDat = t; }
  84.         
  85.         bool HasScript() const                                                { return (hFileInfo.ioFlXFndrInfo.fdScript & 0x80) != 0; }
  86.         ScriptID Script() const                                                { return ScriptID::Make( hFileInfo.ioFlXFndrInfo.fdScript & 0x7f ); }
  87.         
  88.         void HaveNoScript()                                                    { hFileInfo.ioFlXFndrInfo.fdScript = 0; }
  89.         void HaveScript( ScriptID s )                                        { hFileInfo.ioFlXFndrInfo.fdScript = s.ID() | 0x80; }
  90.  
  91.         DirectoryID PutAwayPlace() const                                    { return DirectoryID::Make( hFileInfo.ioFlXFndrInfo.fdPutAway ); }
  92.         void SetPutAwayPlace( DirectoryID id )                            { hFileInfo.ioFlXFndrInfo.fdPutAway = id.Number(); }
  93.         
  94.         
  95.         class DirectoryCatInfo: public DirInfo
  96.           {
  97.             private:
  98.                 bool Attribute( uint8 bit ) const                                { return ( ioFlAttrib & bit ) != 0; }
  99.                 bool Access( uint8 bit ) const                                    { return ( ioACUser & bit ) != 0; }
  100.                 
  101.             public:
  102.                 bool Shared() const                                                    { return Attribute( 0x04 ); }
  103.                 bool IsMountedSharePoint() const                                    { return Attribute( 0x08 ); }
  104.                 bool IsSharePoint() const                                            { return Attribute( 0x20 ); }
  105.  
  106.                 bool CantSeeFolders() const                                        { return Access( 0x01 ); }
  107.                 bool CantSeeFiles() const                                            { return Access( 0x02 ); }
  108.                 bool CantMakeChanges() const                                        { return Access( 0x04 ); }
  109.                 bool NotOwner() const                                                { return Access( 0x80 ); }
  110.                 
  111.                 DirectoryID ID() const                                                { return DirectoryID::Make( ioDrDirID ); }
  112.                 uint16 FileCount() const                                            { return ioDrNmFls; }
  113.           };
  114.         
  115.         
  116.         class FileCatInfo: public HFileInfo
  117.           {
  118.             private:
  119.                 bool Attribute( uint8 bit ) const                                { return ( ioFlAttrib & bit ) != 0; }
  120.                 bool Flag( uint16 bit ) const                                        { return ( ioFlFndrInfo.fdFlags & bit ) != 0; }
  121.                 void SetFlag( uint16 bit )                                            { ioFlFndrInfo.fdFlags |= bit; }
  122.                 void ClearFlag( uint16 bit )                                        { ioFlFndrInfo.fdFlags &= ~bit; }
  123.  
  124.             public:
  125.                 int16 ReferenceNumber() const                                        { return ioFRefNum; }
  126.                 
  127.                 bool IsOpen() const                                                    { return Attribute( 0x80 ); }
  128.                 
  129.                 FileType Type() const                                                { return FileType::Make( ioFlFndrInfo.fdType ); }
  130.                 FileSignature Signature() const                                    { return FileSignature::Make( ioFlFndrInfo.fdCreator ); }
  131.                 
  132.                 void SetType( FileType t )                                            { ioFlFndrInfo.fdType = t.Type(); }
  133.                 void SetSignature( FileSignature s )                            { ioFlFndrInfo.fdCreator = s.Signature(); }
  134.                 
  135.                 bool IsAlias() const                                                    { return Flag( kIsAlias ); }
  136.                 bool HasBundle() const                                                { return Flag( fHasBundle ); }
  137.                 bool IsStationery() const                                            { return Flag( kIsStationery ); }
  138.                 bool HasNoInits() const                                                { return Flag( 0x80 ); }
  139.                 bool IsSharableApplication() const                                { return Flag( kIsShared ); }
  140.  
  141.                 void BeAlias()                                                            { SetFlag( kIsAlias ); }
  142.                 void HaveBundle()                                                        { SetFlag( fHasBundle ); }
  143.                 void BeStationery()                                                    { SetFlag( kIsStationery ); }
  144.                 void HaveNoInits()                                                    { SetFlag( 0x80 ); }
  145.                 void BeSharableApplication()                                        { SetFlag( kIsShared ); }
  146.  
  147.                 void BeNotAlias()                                                        { ClearFlag( kIsAlias ); }
  148.                 void HaveNoBundle()                                                    { ClearFlag( fHasBundle ); }
  149.                 void BeNotStationery()                                                { ClearFlag( kIsStationery ); }
  150.                 void HaveInits()                                                        { ClearFlag( 0x80 ); }
  151.                 void BeNotSharableApplication()                                    { ClearFlag( kIsShared ); }
  152.                 
  153.                 FileID ID() const                                                        { return FileID::Make( ioDirID ); }
  154.  
  155.                 uint32 ClumpSize() const                                            { return ioFlClpSiz; }
  156.                 
  157.                 
  158.                 class DataForkInfo: public HFileInfo
  159.                   {
  160.                     private:
  161.                         bool Attribute( uint8 bit ) const                                { return ( ioFlAttrib & bit ) != 0; }
  162.                     
  163.                     public:
  164.                         uint32 LogicalLength() const                                        { return ioFlLgLen; }
  165.                         uint32 PhysicalLength() const                                        { return ioFlPyLen; }
  166.                         uint16 FirstAllocationBlock() const                                { return ioFlStBlk; }
  167.  
  168.                         bool IsOpen() const                                                    { return Attribute( 0x08 ); }
  169.                         
  170.                         bool Exists() const                                                    { return ioFlStBlk != 0; }
  171.                   };
  172.                 
  173.                 
  174.                 class ResourceForkInfo: public HFileInfo
  175.                   {
  176.                     private:
  177.                         bool Attribute( uint8 bit ) const                                { return ( ioFlAttrib & bit ) != 0; }
  178.                     
  179.                     public:
  180.                         uint32 LogicalLength() const                                        { return ioFlRLgLen; }
  181.                         uint32 PhysicalLength() const                                        { return ioFlRPyLen; }
  182.                         uint16 FirstAllocationBlock() const                                { return ioFlRStBlk; }
  183.  
  184.                         bool IsOpen() const                                                    { return Attribute( 0x04 ); }
  185.                         
  186.                         bool Exists() const                                                    { return ioFlRStBlk != 0; }
  187.                   };
  188.                 
  189.                 
  190.                 DataForkInfo& Data()                                    { return static_cast< DataForkInfo& >( static_cast< HFileInfo &>( *this ) ); }
  191.                 const DataForkInfo& Data() const                    { return static_cast< const DataForkInfo& >( static_cast< const HFileInfo& >( *this ) ); }
  192.  
  193.                 ResourceForkInfo& Resources()                        { return static_cast< ResourceForkInfo& >( static_cast< HFileInfo& >( *this ) ); }
  194.                 const ResourceForkInfo& Resources() const        { return static_cast< const ResourceForkInfo& >( static_cast< const HFileInfo& >( *this ) ); }
  195.           };
  196.         
  197.         
  198.         DirectoryCatInfo& Directory()                                { Assert( IsDirectory() );    return static_cast< DirectoryCatInfo& >( dirInfo ); }
  199.         const DirectoryCatInfo& Directory() const                { Assert( IsDirectory() ); return static_cast< const DirectoryCatInfo& >( dirInfo ); }
  200.         
  201.         FileCatInfo& File()                                            { Assert( !IsDirectory() ); return static_cast< FileCatInfo& >( hFileInfo ); }
  202.         const FileCatInfo& File() const                            { Assert( !IsDirectory() ); return static_cast< const FileCatInfo& >( hFileInfo ); }
  203.   };
  204.  
  205. #endif
  206.